class Solution(object):
    def isUgly(self, num):
        """
        :type num: int
        :rtype: bool
        """
        if num == 1:
            return True
        if num <= 0:
            return False
        if num % 2 == 0:
            return self.isUgly(num / 2)
        if num % 3 == 0:
            return self.isUgly(num / 3)
        if num % 5 == 0:
            return self.isUgly(num / 5)
        if num == 1:
            return True
        return False

if __name__ == '__main__':
    so = Solution()
    print so.isUgly(1)